package com.atguigu.gmall.weball.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.feign.product.CategoryTreeFeignClient;
import com.atguigu.gmall.model.product.to.CategoryTreeTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

/**
 * @Author:lyd
 **/
@Controller
public class IndexController {

    @Autowired
    CategoryTreeFeignClient categoryTreeFeignClient;

    @GetMapping("/")
    public String index(Model model) {
        Result<List<CategoryTreeTo>> data = categoryTreeFeignClient.getCategoryTreeTo();
        model.addAttribute("list",data.getData());
        return "index/index";
    }
}
